package com.dao;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
       /* String name = new EmpDaoImpl().getNameById(2);
        System.out.println(name);

        String name2 = new DeptDaoImpl().getNameById(2);
        System.out.println(name2);*/

//第二步：

        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        String name = context.getBean("empDao", EmpDao.class).getNameById(2);
        System.out.println(name);

        String name2 = context.getBean("deptDao", DeptDao.class).getNameById(2);
        System.out.println(name2);
    }
}
